/*
 * @lc app=leetcode.cn id=2248 lang=typescript
 *
 * [2248] 多个数组求交集
 */

// @lc code=start
function intersection(nums: number[][]): number[] {
    if (nums.length === 0) return [];
    if (nums.length === 1) return nums[0].sort((a, b) => a - b);
    const [first, second, ...other] = nums;
    let item = first.filter((i) => second.includes(i));
    other.forEach((i) => {
        item = item.filter((it) => i.includes(it));
    });
    return item.sort((a, b) => a - b);
}
// @lc code=end
